//-----------------------------------------------------------------------------
//  File          : SecuFile.h
//  Module        :
//  Description   : Header file for SecuFile.c
//  Author        : Lewis
//  Notes         :
//
// ============================================================================
// | Naming conventions                                                       |
// | ~~~~~~~~~~~~~~~~~~                                                       |
// |        Struct define : Leading T                                         |
// |         Struct/Array : Leading s                                         |
// |             Constant : Leading K                                         |
// |      Global Variable : Leading g  (variable use outside one C file)      |
// |                                                                          |
// |   BYTE( 8 Bits) size : Leading b                                         |
// |   CHAR( 8 Bits) size : Leading c                                         |
// |   WORD(16 Bits) size : Leading w                                         |
// |  DWORD(32 Bits) size : Leading d                                         |
// |    int(32 Bits) size : Leading i                                         |
// | DDWORD(64 Bits) size : Leading dd                                        |
// |              Pointer : Leading p                                         |
// |                                                                          |
// |    Function argument : Leading a                                         |
// |       Local Variable : All lower case                                    |
// |                                                                          |
// | Examples:                                                                |
// |                Array : Leading s, (sb = arrary of byte, etc)             |
// |              Pointer : Leading p, (pb = pointer of byte, etc)            |
// ============================================================================
//
//  Date          Who         Action
//  ------------  ----------- -------------------------------------------------
//  29 Sept 2008  Lewis       Initial Version (with new CD nameing convention)
//-----------------------------------------------------------------------------
#ifndef _INC_SECUFILE_H_
#define _INC_SECUFILE_H_
#include "common.h"
#include "key2dll.h"

//-----------------------------------------------------------------------------
//    Defines
//-----------------------------------------------------------------------------
// Move to Key2dll.h
//Key status
//#define KEY_STATUS_LOADED       0x01
//#define KEY_STATUS_DECRYPT      0x02
//#define KEY_STATUS_MASTER       0x04
//#define KEY_STATUS_SINGLE       0x08
//#define KEY_STATUS_DOUBLE       0x10
//#define KEY_STATUS_TRIPLE       0x18

#define MAX_KEYBANK_SUPPORT    40
#define MAX_DUKPTKEY_SUPPORT   40
struct KEY_BANK {
  BYTE b_status;
  BYTE sb_lkey[8];
  BYTE sb_rkey[8];
  BYTE sb_tkey[8];
};

struct SECUR_DATA {
  struct KEY_BANK s_keybank[MAX_KEYBANK_SUPPORT];
  T_KEYBANK       s_dukpt[MAX_KEYBANK_SUPPORT];
  WORD w_crc_val;
};

extern struct SECUR_DATA gSecurData;

//-----------------------------------------------------------------------------
//    Functions API
//-----------------------------------------------------------------------------
extern BOOLEAN DukptKeyReset(BYTE aKeyIdx);
extern void ResetKeyBank(int aKeyIdx);
extern void KeyStatus(BYTE *aStatusStr);
extern void SecuFileInit(void);
extern void UpdateSecurData(void);

#endif // _INC_SECUFILE_H_

